using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Dao;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    public class ProgramBO
    {
        /// <summary>
        /// ProgramDao object
        /// </summary>
        private readonly ProgramDao _programDao = new ProgramDao();

        /// <summary>
        /// Adds the program.
        /// </summary>
        /// <param name="newProgram">The new program.</param>
        /// <returns></returns>
        public bool AddProgram(Program newProgram)
        {
            return _programDao.AddProgram(newProgram);
        }

        /// <summary>
        /// Gets the program by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public Program GetProgramById(int id)
        {
            return _programDao.GetProgramById(id);
        }

        /// <summary>
        /// Edits the program.
        /// </summary>
        /// <param name="newProgram">The new program.</param>
        /// <returns></returns>
        public bool EditProgram(Program newProgram)
        {
            return _programDao.EditProgram(newProgram);
        }

        /// <summary>
        /// Edits the status.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public Program EditStatus(int id)
        {
            return _programDao.EditStatus(id);
        }

        /// <summary>
        /// Checks the name of the program.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public bool CheckProgramName(string name)
        {
            return _programDao.CheckProgramName(name);
        }

        /// <summary>
        /// Gets the program list.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public IQueryable<Program> GetProgramList(ProgramFilter filter, string sortType, int startRowIndex, int maxRows)
        {
            return _programDao.GetList(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Gets the list count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public int GetListCount(ProgramFilter filter)
        {
            return _programDao.GetListCount(filter);
        }
    }
}